<template>
  <div class="course-list">
    <template v-if="data">
      <div
        class="course-list-item"
        @click="goto('/aviation/detail', { id: item.id })"
        v-for="item in data"
        :key="item.id"
      >
        <div class="img-container">
          <img :src="item.course_ku_single_pic" alt="" />
        </div>
        <div class="details">
          <div class="title">{{ item.course_ku_title }}</div>
          <div class="footer">
            <div class="address">
              <IconAddress class="svg" fill="#70818C"></IconAddress>
              <div>
                <span> {{ $t("content.aviation.start_course_address") }}：</span
                >{{ item.course_address_title }}
              </div>
            </div>
            <div class="time">{{ `${item.y}.${item.m}.${item.d}` }}</div>
          </div>
        </div>
      </div>
    </template>
    <template v-else>
      <div class="course-list-item none" v-for="i in 16" :key="i">
        <div class="img-container">
          <Skeleton avatar height="100%" block></Skeleton>
        </div>
        <div class="details pc">
          <Skeleton :rows="2"></Skeleton>
        </div>
        <div class="details mobile">
          <Skeleton :rows="2" mobile></Skeleton>
        </div>
      </div>
    </template>
  </div>
</template>

<script setup lang="ts">
type Props = {
  data: any[];
};
defineProps<Props>();
</script>
<style scoped lang="less">
.course-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  .course-list-item {
    padding: 8px;
    border: 1px solid #d6d8d9;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    &.none {
      &:hover {
        border-color: #d6d8d9;
        cursor: default;
      }
    }
    &:hover {
      border-color: var(--yd-primary-color);
      cursor: pointer;
    }
    .img-container {
      border-radius: 20px;
      height: 290px;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
        overflow: cover;
        object-fit: cover;
      }
    }
    .details {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 8px;
      &.mobile {
        display: none;
      }
      padding: 16px;
      .title {
        flex: 1;
        color: #323232;
        font-size: 20px;
        font-weight: 600;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
      .footer {
        font-size: 16px;
        color: #70818c;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .address {
          .svg {
            display: none;
          }
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .course-list {
    padding: 61px 0;
    grid-template-columns: repeat(2, 1fr);
    gap: 61px;
    padding-bottom: 0;
    .course-list-item {
      padding: 0;
      border-radius: 51px;
      .img-container {
        border-radius: 51px;
        height: 584px;
      }
      .details {
        gap: 41px;
        &.mobile {
          display: block;
        }
        &.pc {
          display: none;
        }
        padding: 61px;
        .title {
          font-size: 72px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          white-space: normal;
        }
        .footer {
          font-size: 51px;
          .address {
            display: flex;
            align-items: center;
            gap: 20px;
            span {
              display: none;
            }
            .svg {
              display: block;
            }
          }
        }
      }
    }
  }
}
</style>
